package com.edoomath.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.edoomath.entity.course.UserCourseTaskMedia;
import com.edoomath.entity.usercourse.ProgressStatus;
import com.edoomath.entity.usercourse.UserCourseTask;

/**
 * 
 * @author mohanlan
 *
 */
@Dao(value = "hibernate")
public interface UserCourseTaskDao {
	
	/**
	 * 
	 * @param id
	 * @return
	 */
	@Query("FROM UserCourseTask WHERE id = :id AND disabled = false")
    public UserCourseTask load(@Variable("id") Long id);
	
	/**
	 * 
	 * @return
	 */
	@Query("FROM UserCourseTask WHERE disabled = false AND status = :status")
	public List<UserCourseTask> list(@Variable("status") ProgressStatus progressStatus);
	
	/**
	 * 
	 * @param task
	 * @return
	 */
	@Query("FROM UserCourseTaskMedia WHERE userCourseTask = :task AND disabled = false ORDER BY id ASC")
	public List<UserCourseTaskMedia> listUserCourseTaskMedia(@Variable("task") UserCourseTask task);
	
	/**
	 * 
	 * @param task
	 * @param type
	 * @return
	 */
	@Query("FROM UserCourseTaskMedia WHERE userCourseTask = :task AND mediaType = :type AND disabled = false ORDER BY id ASC")
	public List<UserCourseTaskMedia> listUserCourseTaskMedia(@Variable("task") UserCourseTask task, @Variable("type") String type);
	
}
